<?php

namespace App\Admin\Extensions;

use App\Model\UserActLog;
use Encore\Admin\Admin;

class AvatarVerify extends BaseAction
{
    protected function render()
    {
        Admin::script($this->script($this->actionUrl));
        $failbtn = $this->buildButton('fail', '违规不通过', [
            'id' => $this->id,
            'status' => UserActLog::FLAG_BAD,
            'extra' => $this->row->userProfile ? $this->row->userProfile->role : 1,
        ]);
        $okbtn = $this->buildButton('ok', '通过', [
            'id' => $this->id,
            'status' => UserActLog::FLAG_OK,
            'extra' => $this->row->userProfile ? $this->row->userProfile->role : 1,
        ]);
        $str = [];
        if (in_array($this->row->flag, [UserActLog::FLAG_OK])) {
            $str  = [$failbtn];
        } elseif (UserActLog::FLAG_ING == $this->row->flag) {
            $str  = [$failbtn, $okbtn];
        } elseif ($this->row->flag == UserActLog::FLAG_BAD) {
            // $str  = [$okbtn];
        }
        return implode('<br/><br/>', $str);
    }
}
